﻿using System.Drawing;
using GraphDrawing2.V2.Concrete.Model;

namespace GraphDrawing2.V2.Graph.Model
{
    public class Shape : VisualElement<ShapeModel, IShapeView>, IZOrdered 
    {
        protected override ShapeModel CreateModel()
        {
            return new ShapeModel(ShapeType.Circle);
        }

        protected override IShapeView CreateView()
        {
            return new ShapeView();
        }

        protected override IHitTestResult HitTestInternal(PointF localPoint)
        {
            return view.Contains(localPoint) ? new ElementHitTest(this) : (IHitTestResult) NoneHitTest.INSTANCE;
        }

        public void BringToFront()
        {
//            commandManager.Add(new BringToFrontCommand(this, globalModel.ZOrder));
            Owner.BringToFront(this);
        }
    }

    public class ShapeModel : IVisualItem
    {
        public ShapeType ShapeType { get; private set; }
        public int Width { get; set; }
        public int Height { get; set; }
        public PointF Position { get; set; }
        public StateHints Hints { get; set; }

        public ShapeModel(ShapeType shapeType)
        {
            ShapeType = shapeType;
            Width = 100;
            Height = 100;
        }
    }

    public enum ShapeType
    {
        Circle,
        Rectangle
    }
}